Exercise 1
setwd("~/COLLEGE BABY!!!/Senior year/S2/Bio 497G/Labs/Data")
library(ggplot2)
SNPs <- read.table("23andMe_complete.txt", header = TRUE, sep = "\t")
a <- ggplot(SNPs, aes(chromosome)) + geom_bar(color= "steelblue", fill="steelblue")
a + ggtitle("Total SNP counts for each chromosome") + ylab("SNP counts") + xlab("Chromosome number")
Exercise 2
ab <- ggplot(SNPs, aes(chromosome, fill = genotype)) + geom_bar(color = "black")
ab + ggtitle("Total SNPs count") + scale_y_continuous(trans= 'log10') + ylab("SNP counts") + xlab("Chromosome number")
Exercise 3
ppi <- 300
png("Lab3_ex5_graph.png", width=6*ppi, height=6*ppi,res=ppi)
ad <- ggplot(data = SNPs) + geom_bar(mapping = aes(x = chromosome, fill = genotype), position = "dodge")
ad + ggtitle("Sorted based on genotype/ chromosome comparison")
Exercise 4
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
ae <- ggplot(SNPs, aes(chromosome, fill = genotype)) + geom_bar(position = "dodge") + facet_wrap(~chromosome, scales = "free", strip.position = c("bottom"))
ae + ggtitle("SNPs per chromosome sorted using facet_wrap") + labs(y= "SNP counts", x= "chromosome number")
Exercise 5
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
p <- ggplot(SNPs, aes(chromosome, fill = genotype)) + geom_bar(position = "dodge") + facet_wrap(~chromosome, scales = "free", ncol = 5) + ggtitle("SNPs per chromosome sorted using facet_wrap") + labs(y= "SNP counts", x= "chromosome number")
ggplotly(p)
Exercise 6
library(plotly)
SNPs$chromosome = "Y"
pp <- ggplot(SNPs, aes(chromosome, fill = genotype)) + geom_bar(position = "dodge") + ggtitle("SNPs on the Y chromosome") + labs(y= "SNP counts", x= "chromosome")
ggplotly(pp)